/**
 * 
 */

package CCT220_Aula12_Exercicio01_13106.view.disciplina;


import javax.swing.JOptionPane;

import CCT220_Aula12_Exercicio01_13106.info.academico.disciplina.Disciplina;
import CCT220_Aula12_Exercicio01_13106.info.academico.disciplina.VetorDisciplina;


/**
 * ******************************
 * Project: CCT220
 * Package: CCT220_Aula12_Exercicio01_13106.view.disciplina
 * Class: viewDisciplina
 * Last Change: 27/09/2011 16:10:52
 * Description:
 * ******************************
 * 
 * @author marcel
 * @author 13106
 * 
 */
public class viewDisciplina {

	private final VetorDisciplina objDisciplinas;


	/**
	 * ******************************
	 * Constructor for
	 * Package: CCT220_Aula12_Exercicio01_13106.view.disciplina
	 * Class: viewDisciplina
	 * LastChange: 27/09/2011 16:10:52
	 * ******************************
	 * 
	 */
	public viewDisciplina() {

		objDisciplinas = new VetorDisciplina();
		menu();
	}


	/**
	 * ******************************
	 * Package: CCT220_Aula12_Exercicio01_13106.view.disciplina
	 * Class: viewDisciplina
	 * Method: menu
	 * Last Change: 27/09/2011 16:12:15
	 * Description:
	 * ******************************
	 * 
	 */
	public void menu() {

		int escolha = 0;
		String escolhaInformada = "";
		int codigo = 0;
		String nome = "";
		int cargaHoraria = 0;
		do {
			do {
				escolhaInformada = JOptionPane
				        .showInputDialog("Escolha uma opção do menu:\n"
				                + "[1] Adiciona disciplina\n"
				                + "[2] Remove disciplina\n"
				                + "[3] Lista disciplinas\n" + "[4] Finaliza");
				escolha = Integer.parseInt(escolhaInformada);
			} while ((escolha < 1) || (escolha > 4));
			switch (escolha) {
				case 1:

					codigo = Integer.parseInt(JOptionPane
					        .showInputDialog("Informe o código"));
					nome = JOptionPane.showInputDialog("Informe o nome");
					cargaHoraria = Integer.parseInt(JOptionPane
					        .showInputDialog("Informe o carga horária"));
					objDisciplinas.addDisciplina(new Disciplina(codigo, nome,
					        cargaHoraria));
					break;
				case 2:
					codigo = Integer.parseInt(JOptionPane
					        .showInputDialog("Informe o código"));
					objDisciplinas.removeDisciplina(codigo);
					break;

				case 3:
					JOptionPane.showMessageDialog(null, objDisciplinas
					        .imprimeDisciplinas());
					break;
				default:
					System.exit(0);
			}
		} while (true);
	}
}
